<template>
    <div>
        <el-breadcrumb separator="/" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item><a href="/">{{title}}</a></el-breadcrumb-item>
        </el-breadcrumb>
        <div v-html="body"></div>
    </div>
</template>

<style>
    .breadcrumb {
        padding-top: 30px;
        font-size: 16px;
    }
</style>

<script>
    import axios from 'axios'

    export default {
        created() {
            this.getDetail()
        },
        methods: {
            getDetail() {
                let _this = this;
                let params = this.$route.params
                axios.get('/api/detail?id=' + params.id)
                    .then(function (response) {
                        if (response.status = 200) {
                            let data = response.data.data
                            let body = JSON.parse(data)
                            //console.log(body.body)
                            _this.body = body.body
                            let matches = body.body.match(/<h2 class="question-title">(.+)<\/h2>/g)
                            _this.title = matches[0].replace(/<\/?.+?>/g, "");
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            }
        },
        data() {
            return {
                body: "正在获取...",
                title: "标题"
            };
        }
    }
</script>